#include <cstdint>
#include <iostream>
#include <vector>

using ll = int64_t;

ll n,q;
std::vector<ll> t;
std::vector<ll> v;
std::vector<ll> lazy;

ll create(ll cur,ll l,ll r){
    if(l==r){
        t[cur]=v[l];
        return v[l];
    }
    ll mid = (l+r)/2;
    t[cur]=create(2*cur, l, mid)
        + create(2*cur+1, mid+1, r);
    return t[cur];
}

ll rangeadd(ll cur, ll l, ll r, ll ql, ll qr, ll val) {
    if (lazy[cur] != 0) {
        t[cur] += lazy[cur] * (r - l + 1);
        if (l != r) {
            lazy[2 * cur] += lazy[cur];
            lazy[2 * cur + 1] += lazy[cur];
        }
        lazy[cur] = 0;
    }
    if (ql > r || qr < l) return t[cur];
    if (ql <= l && r <= qr) {
        t[cur] += val * (r - l + 1);
        if (l != r) {
            lazy[2 * cur] += val;
            lazy[2 * cur + 1] += val;
        }
        return t[cur];
    }
    ll mid = (l + r) / 2;
    return t[cur] = rangeadd(2 * cur, l, mid, ql, qr, val)
                   + rangeadd(2 * cur + 1, mid + 1, r, ql, qr, val);
}

ll rangequery(ll cur, ll l, ll r, ll ql, ll qr) {
    if (lazy[cur] != 0) {
        t[cur] += lazy[cur] * (r - l + 1);
        if (l != r) {
            lazy[2 * cur] += lazy[cur];
            lazy[2 * cur + 1] += lazy[cur];
        }
        lazy[cur] = 0;
    }
    if (ql > r || qr < l) return 0;
    if (ql <= l && r <= qr) return t[cur];
    ll mid = (l + r) / 2;
    return rangequery(2 * cur, l, mid, ql, qr)
         + rangequery(2 * cur + 1, mid + 1, r, ql, qr);
}

int main(){
    std::cin>>n>>q;
    t.resize((n+1)*4);
    v.resize(n+1);
    lazy.resize((n+1)*4);
    for(ll i=1; i<=n; i++){
        std::cin>>v[i];
    }
    create(1, 1, n);
    while(q--){
        ll op;
        std::cin>>op;
        if(op==1){
            ll x,y,z;
            std::cin>>x>>y>>z;
            rangeadd(1, 1, n, x, y, z);
        }else{
            ll x,y;
            std::cin>>x>>y;
            std::cout<<rangequery(1, 1, n, x, y)<<'\n';
        }
    }
}